//
//  MSubOrder.m
//  RRQS
//
//  Created by kyjun on 16/3/24.
//
//

#import "MSubOrder.h"

@implementation MSubOrder

-(instancetype)initWithItem:(NSDictionary *)item{
    self = [super init];
    if(self){
        _rowID = [item objectForKey:@"item_id"];
        _orderID = [item objectForKey:@"main_id"];
        _subOrderID = [item objectForKey:@"order_id"];
        _payMoney = [item objectForKey:@"food_amount"];
        _createDate = [item objectForKey:@"add_time"];
        _status = [[item objectForKey:@"status"] integerValue];
        _sendStatus = [item objectForKey:@"sendstatus"];
        _storeName = [item objectForKey:@"site_name"];
        _storeAddress = [item objectForKey:@"shopaddress"];
        _lng = [ item objectForKey:@"lng"];
        _lat = [item objectForKey:@"lat"];
          _phoneAddress = [item objectForKey: @"phone_addr"];
        _location = [item objectForKey:@"location"];
           }
    return self;
}

-(instancetype)initWithOrder:(NSDictionary *)item{
    self = [super init];
    if(self){
        _rowID = [item objectForKey:@"itemid"];
        _orderID = [item objectForKey:@"main_id"];
        _subOrderID = [item objectForKey:@"order_id"];
        _payMoney = [item objectForKey:@"food_amount"];
        _createDate = [item objectForKey:@"add_time"];
        _status = [[item objectForKey:@"status"] integerValue];
       // _sendStatus = [item objectForKey:@"sendstatus"];
        _storeName = [item objectForKey:@"site_name"];
        _storeAddress = [item objectForKey:@"site_addr"];
        _lng = [ item objectForKey:@"lng"];
        _lat = [item objectForKey:@"lat"];
          _phoneAddress = [item objectForKey: @"phone_addr"];
        _location = [item objectForKey:@"location"];
        _empID = [item objectForKey:@"emp_id"];
        _userName = [item objectForKey:@"uname"];
        _userPhone = [item objectForKey:@"phone"];
        _getTime = [item objectForKey:@"get_time"];
        _sendTime = [item objectForKey:@"send_time"];
    }
    return self;
}


-(double)distanceBetweenOrderBy:(double)lat1 :(double)lat2 :(double)lng1 :(double)lng2{
    double dd = M_PI/180;
    double x1=lat1*dd,x2=lat2*dd;
    double y1=lng1*dd,y2=lng2*dd;
    double R = 6371004;
    double distance = (2*R*asin(sqrt(2-2*cos(x1)*cos(x2)*cos(y1-y2) - 2*sin(x1)*sin(x2))/2));
    //km  返回
    return  distance/1000;
    
    //返回 m
    //return   distance;
    
}

@end
